/**
 * Created by xiey on 2016/4/18.
 */
var path        = require('path'),
    gulp        = require('gulp'),
    inject      = require('gulp-inject'),
    conf        = require('./common/conf'),
    wiredep     = require('wiredep').stream,
    browserSync = require('browser-sync');

gulp.task('inject-reload', ['inject'], function () {
    browserSync.reload();
});

gulp.task('inject', function () {

    return gulp.src(path.join(conf.paths.src, 'index.html'))
        .pipe(inject(gulp.src([path.join(conf.paths.src, 'js/**/*.js'), path.join(conf.paths.src, 'css/**/*.css')], {read: false}), {relative: true}))
        .pipe(wiredep({
            directory: 'node_modules',
            bowerJson: require('../package.json')
        }))
        .pipe(gulp.dest(conf.paths.tmp));
});